﻿using System;
using System.Collections.Generic;
using System.Text;

namespace csharpcore7_ch3_Implicitly
{
    public class BaseClass
    {
        public int X;
        public BaseClass() { X = 1; }
    }
    public class SubClass : BaseClass
    {
        public int Y;

        //如果子类省略base关键字，那么基类的无参数构造器将被隐式调用
        public SubClass() {
            Y = X+1;
        }
    }
    class Chapter3_2_8_1ImplicitlyCallTheParameterlessConstructorOfTheBaseClass
    {
        static void _Main()
        {           
            SubClass s = new SubClass();
            Console.WriteLine(s.X);
            Console.WriteLine(s.Y);
        }
    }
}
